stages:
  - build
  - upload
  - deploy

build:
  stage: build
  rules:
    - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
  script:
    - docker build -t back-mqh/mqh-app:$CI_COMMIT_SHORT_SHA ./MQH

upload:
  stage: upload
  rules:
    - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
  needs:
    - job: build
  script:
    - kind load docker-image back-mqh/mqh-app:${CI_COMMIT_SHORT_SHA}

deploy:
  stage: deploy
  rules:
    - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
  needs:
    - job: upload
  environment:
    name: production
  script:
  # # - kubectl create configmap myapp-conf --from-file=< etc или config>/ --namespace=default -o yaml --dry-run=client | kubectl apply -f -
    - kubectl set image deployment/django-deployment mqh-backend=back-mqh/mqh-app:${CI_COMMIT_SHORT_SHA}
    - kubectl get pods -o wide
